#!/bin/sh


#CONID=zhiliaositemap 
#CONKEY=sitemap123%212020
#GIT_REPOSITORY=codeup.aliyun.com/zhiliao/zhiliaoketang/zl_news_sitemap.git
GIT_ADDRESS=https://zhiliaositemap:b191849787c9cc3aecdaa831f2d739c0@codeup.aliyun.com/zhiliao/zhiliaoketang/zl_news_sitemap.git

folder=zl_news_sitemap

#如果没有这个文件夹，那么clone
if [ ! -d "$folder" ]; then
  git clone $GIT_ADDRESS

  if [[ "$?" != 0 ]];then
    echo -e "\033[41m git clone fail \033[0m"
  fi

  #第一次没有sitemap仓库，就拉取
  exit 1
fi

echo -e "\033[32m start git \033[0m"

cd $folder

echo -e "\033[32m start pull  \033[0m" 

git pull

if [[ "$?" != 0 ]];then
 echo -e "\033[41m pull fail \033[0m" 
 exit 2
fi

echo -e "\033[32m pull success  \033[0m" 
exit 0
